﻿#region Header

/*
 * Created by SharpDevelop.
 * User: chenhu
 * Date: 2010/6/27
 * Time: 18:04
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

#endregion Header

namespace TestIndexChart
{
    using IndexChart.Graph;
    using System;
    using System.Windows.Forms;
    using ZedGraph;

    /// <summary>
    /// Description of Form2.
    /// </summary>
    public partial class Form2 : UserControl
    {
        

        StockPtDataSource ds = new StockPtDataSource();
        int i = 0;
        int ii = 1;
        StockPointList list = DataGenerator.GenerateDateData(20081004, 400);
        System.Windows.Forms.Timer _timer;

        

        

        public Form2()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            UCIndexChart.SetCurrentLanguange(LanguageType.zh_CN);
            this.ucPriceChart1.DrawDefaultDateChart();

            //for(int I)
            _timer = new System.Windows.Forms.Timer();
            _timer.Interval = 500;
            _timer.Tick += new EventHandler(_timer_Tick);

            ds.AddPoints(list);

            this.ucPriceChart1.Displayname = "TigEra";
            this.ucPriceChart1.DataSource = ds;

            this.ucPriceChart1.Chart.Draw();
        }

        

        

        private void DrawMinute()
        {
            //_timespans.Add(new ZedGraph.Tuple<DateTime,DateTime>(new DateTime(2010,3,13,13,0,0),new DateTime(2010,3,13,14,0,0)));
            //_timespans.Add(new ZedGraph.Tuple<DateTime, DateTime>(new DateTime(2010, 3, 13, 18, 0, 0), new DateTime(2010, 3, 13, 22, 0, 0)));
            this.ucPriceChart1.DrawDefaultMinuteChart(new ZedGraph.Tuple<DateTime, DateTime>(new DateTime(2010, 3, 13, 9, 30, 0), new DateTime(2010, 3, 13, 10, 0, 0)));

            ds.AddPoints(DataGenerator.GenerateRedomSecondData(20100313, 930, 0, 0, 4000));
            this.ucPriceChart1.DataSource = ds;
            this.ucPriceChart1.Chart.Draw();
        }

        private void testc()
        {
            StockPtDataSource ds1 = new StockPtDataSource();

            StockPointList list = DataGenerator.GenerateDateData(20091004, 400);
            ds1.AddPoints(list);
            this.ucPriceChart1.DataSource = ds1;
            this.ucPriceChart1.Chart.Draw();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            this.ucPriceChart1.Chart.Clear();
            this.ucPriceChart1.DataSource = null;

            DrawMinute();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            (this.ucPriceChart1.Chart.Panes[0] as CandlePane).DrawCurrentQuote(list[ii++] as StockPt);
            this.ucPriceChart1.Chart.Draw();
            //Thread.Sleep(500);
        }

        void _timer_Tick(object sender, EventArgs e)
        {
            if (i == 3000)
            {
                _timer.Dispose();
                return;
            }
            ds.AddPoints(list[i++] as StockPt);

            this.ucPriceChart1.Chart.Draw();
        }

        
    }
}